package com.yvdedu.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;

@Entity
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	@Column(unique = true, nullable = false)
	private String name;
	
	@Column(unique = true)
	private String phone;

	@Column(unique = true)
	private String email;

	@Column(unique = true,nullable = false)
	private String pwd;

	@OneToOne
	@PrimaryKeyJoinColumn
	private UserInfo info;

	@ManyToOne
	@JoinColumn(name = "roleId")
	private Role role;

	@OneToOne
	@PrimaryKeyJoinColumn
	private VipCard card;
	
	@ManyToMany(mappedBy = "userss")
	private Set<BookTable> table = new HashSet<>();

	public User() {
		super();
	}

	public User(int id, String name, String phone, String email, String pwd, UserInfo info, Role role, VipCard card,
			Set<BookTable> table) {
		super();
		this.id = id;
		this.name = name;
		this.phone = phone;
		this.email = email;
		this.pwd = pwd;
		this.info = info;
		this.role = role;
		this.card = card;
		this.table = table;
	}

	public VipCard getCard() {
		return card;
	}

	public String getEmail() {
		return email;
	}

	public int getId() {
		return id;
	}

	public UserInfo getInfo() {
		return info;
	}

	public String getName() {
		return name;
	}

	public String getPhone() {
		return phone;
	}

	public String getPwd() {
		return pwd;
	}

	public Role getRole() {
		return role;
	}

	public Set<BookTable> getTable() {
		return table;
	}

	public void setCard(VipCard card) {
		this.card = card;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setInfo(UserInfo info) {
		this.info = info;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}


	public void setPwd(String pwd) {
		this.pwd = pwd;
	}


	public void setRole(Role role) {
		this.role = role;
	}

	public void setTable(Set<BookTable> table) {
		this.table = table;
	}
	
	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", phone=" + phone + ", email=" + email + ", pwd=" + pwd
				+ ", info=" + info + ", role=" + role + ", card=" + card + ", table=" + table + "]\n";
	}

	
}
